package org.example.StudentManagementSystem;

import org.example.constant.EnrollmentStatus;

import java.time.LocalDate;

public class Student {
    private int studentId;
    private String studentName;
    private Integer chinese;
    private Integer math;
    private LocalDate EnrollmentDate;
    private String mail;
    private String avatar;
    private EnrollmentStatus enrollmentStatus;

    public Student(int studentId, String studentName, Integer chinese, Integer math, LocalDate enrollmentDate, String mail, String avatar, EnrollmentStatus enrollmentStatus) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.chinese = chinese;
        this.math = math;
        EnrollmentDate = enrollmentDate;
        this.mail = mail;
        this.avatar = avatar;
        this.enrollmentStatus = enrollmentStatus;
    }

    public Student(int studentId, String studentName, Integer chinese, Integer math, LocalDate enrollmentDate, String mail) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.chinese = chinese;
        this.math = math;
        EnrollmentDate = enrollmentDate;
        this.mail = mail;
    }

    public Student(EnrollmentStatus enrollmentStatus) {
        this.enrollmentStatus = enrollmentStatus;
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public LocalDate getEnrollmentDate() {
        return EnrollmentDate;
    }

    public void setEnrollmentDate(LocalDate enrollmentDate) {
        EnrollmentDate = enrollmentDate;
    }

    public Student() {
    }

    public Student(int studentId, String studentName, Integer chinese, Integer math, LocalDate enrollmentDate) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.chinese = chinese;
        this.math = math;
        EnrollmentDate = enrollmentDate;
    }

    public Student(int studentId, String studentName, Integer chinese, Integer math) {
        this(studentId, studentName, chinese, math, LocalDate.now());
    }

    //求学生的总成绩
    public int getTotalScore() {
        return (chinese == null ? 0 : chinese) + (math == null ? 0 : math);
    }

    //显示学生信息（字符串拼接）
    public String toString() {
        return studentId + " " + studentName + " " + chinese + " " + math + " " + mail
                + " " + EnrollmentDate + " " + getTotalScore() + " " + avatar + " " + enrollmentStatus;

    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public Integer getChinese() {
        return chinese;
    }

    public void setChinese(Integer chinese) {
        this.chinese = chinese;
    }

    public Integer getMath() {
        return math;
    }

    public void setMath(Integer math) {
        this.math = math;
    }

    public EnrollmentStatus getEnrollmentStatus() {
        return enrollmentStatus;
    }

    public void setEnrollmentStatus(EnrollmentStatus enrollmentStatus) {
        this.enrollmentStatus = enrollmentStatus;
    }

    public final boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Student student)) {
            return false;
        }
        return studentName.equals(student.studentName);
    }
}
